using System.Windows;
using System.Windows.Markup;
using Common;

namespace ProjectView.Windows
{
	public partial class ProjectReNameWindow : Window, IComponentConnector
	{
		public new string Name
		{
			get
			{
				return projectName.Text;
			}
			set
			{
				projectName.Text = value;
				projectName.Focus();
				projectName.SelectAll();
			}
		}

		public ProjectReNameWindow()
		{
			InitializeComponent();
			projectName.Focus();
		}

		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			if (!Utility.ValidateFileName(projectName.Text))
			{
				MessageBox.Show(string.Format(Utility.GetMessage("msg_filename_illegalcharacter"), Utility.GetFileNameIllegalCharacter().ToString()));
				projectName.Focus();
			}
			else
			{
				base.DialogResult = true;
				Close();
			}
		}

		private void btnCancel_Click(object sender, RoutedEventArgs e)
		{
			Close();
		}
	}
}
